package com.srit.forecast.service.impl;

import java.util.Iterator;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.srit.forecast.bean.City6Hours;
import com.srit.forecast.controller.vo.City6HoursVO;
import com.srit.forecast.dao.City6HoursDao;
import com.srit.forecast.dao.ReportDao;
import com.srit.forecast.service.City6HoursService;

/**
 * 六小时精细化预报service接口，提供AOP
 * 
 * @author guan
 * 
 */
@Service
@Transactional
public class City6HoursServiceImpl implements City6HoursService {
	@Autowired
	private ReportDao reportDao;
	@Autowired
	private City6HoursDao city6HoursDao;

	@Override
	public void doReport(City6HoursVO city6HoursVO) {
		reportDao.save(city6HoursVO.getReport());
		int reportId = reportDao.getMaxId();
		for (Iterator<City6Hours> it = city6HoursVO.getCity6HoursList()
				.iterator(); it.hasNext();) {
			City6Hours tmp = it.next();
			tmp.setReportId(reportId);
			city6HoursDao.save(tmp);
		}
	}

	@Override
	public City6HoursVO doView(int reportId) {
		return null;
	}

}
